clear all;

%% data
GDPG=[3.6 7.51 11.3 10.43 9.69 7.42 7.19 7.49 8.2 8.32 4.87]*0.01;
farmer=[0.463103136366385	0.453802432198222	0.444801667260692	0.436631190937563	0.428805450797380	0.413737527819526	0.397013885430442	0.365185966093827	0.334913107236562	0.319938576033972	0.307443082394377];
entre=[0.153990776280589	0.153137202827486	0.151368401613976	0.152158358199932	0.151296598331587	0.157039695487743	0.162148527972048	0.168740158204568	0.175532563497047	0.180816203604037	0.187263486144681];
worker=1-farmer-entre;
credit_access_ratio=[10.5,15,19,22,24,26];
credit_access_gini=[0.5003 0.4176 0.4209 0.3757 0.3436 0.3149];
GDP(1:11)=1.0;
for i=2:11
    GDP(i)=GDP(i-1)*(1+GDPG(i-1));
end
year_data1=86:1:96;
year_data2=86:2:96;
index_data1=1:length(year_data1);
index_data2=1:length(year_data2);

%% model
baseline=load('baseline.mat');
credit=load('credit.mat');
deposit=load('deposit.mat');

year_model=86:1:96;
index_model=1:length(year_model);

%% draw


fig=figure('Color',[1 1 1], 'Position',[20 50 1200 720]);

ah8 = axes('Parent',fig,'Units','normalized','Position',[0.69 0.1100 0.2134 0.3557]);
plot(year_model, baseline.agg_GDP(index_model), '-b' , 'LineWidth', 2 );
hold on
plot(year_data1, GDP(index_data1), '--k' , 'LineWidth', 2 );
hold on
plot(year_model, credit.agg_GDP(index_model), '-.r' , 'LineWidth', 2 );
hold on
plot(year_model, deposit.agg_GDP(index_model), ':g' , 'LineWidth', 2 );
title( 'F. GDP', 'FontSize',15,'Interpreter','Latex');
xlabel('year', 'FontSize',12,'Interpreter','Latex');
ylabel('GDP', 'FontSize',12,'Interpreter','Latex');
xlim([86 96]);
ylim([1,2.4]);
yticks(1.0:0.3:2.5);
set(gca,'FontSize',12);

% subplot(2,4,2);
ah6 = axes('Parent',fig,'Units','normalized','Position',[0.13 0.1100 0.2134 0.3557]);
plot(year_model, baseline.agg_credit(index_model).*100, '-b' , 'LineWidth', 2 );
hold on
plot(year_data2, credit_access_ratio(index_data2), '--k' , 'LineWidth', 2 );
hold on
plot(year_model, credit.agg_credit(index_model).*100, '-.r' , 'LineWidth', 2 );
hold on
plot(year_model, deposit.agg_credit(index_model).*100, ':g' , 'LineWidth', 2 );
title( 'D. Entrepreneurs with bank loans', 'FontSize',15,'Interpreter','Latex');
xlabel('year', 'FontSize',12,'Interpreter','Latex');
ylabel('entrepreneurs with bank loans (\%)', 'FontSize',12,'Interpreter','Latex');
xlim([86 96]);
ylim([8,30]);
yticks(8:5:28);
set(gca,'FontSize',12);

ah7 = axes('Parent',fig,'Units','normalized','Position',[0.41 0.1100 0.2134 0.3557]);
plot(year_model, baseline.agg_credit_gini(index_model), '-b' , 'LineWidth', 2 );
hold on
plot(year_data2, credit_access_gini(index_data2), '--k' , 'LineWidth', 2 );
hold on
plot(year_model, credit.agg_credit_gini(index_model), '-.r' , 'LineWidth', 2 );
hold on
plot(year_model, deposit.agg_credit_gini(index_model), ':g' , 'LineWidth', 2 );
title( 'E. Credit access Gini', 'FontSize',15,'Interpreter','Latex');
xlabel('year', 'FontSize',12,'Interpreter','Latex');
ylabel('credit access Gini', 'FontSize',12,'Interpreter','Latex');
xlim([86 96]);
ylim([0.2,0.6]);
yticks(0.2:0.1:0.6)
set(gca,'FontSize',12);


ah1 = axes('Parent',fig,'Units','normalized','Position',[0.13 0.5838 0.2134 0.3557]);
plot(year_model, baseline.agg_entre(index_model).*100, '-b' , 'LineWidth', 2 );
hold on
plot(year_model, credit.agg_entre(index_model).*100, '-.r' , 'LineWidth', 2 );
hold on
plot(year_model, deposit.agg_entre(index_model).*100, ':g' , 'LineWidth', 2 );
hold on
plot(year_data1, entre(index_data1).*100, '--k' , 'LineWidth', 2 );
title( 'A. Fraction of entrepreneurs', 'FontSize',15,'Interpreter','Latex');
xlabel('year', 'FontSize',12,'Interpreter','Latex');
ylabel('frac. of entrepreneurs (\%)', 'FontSize',12,'Interpreter','Latex');
legend('model','credit channel','deposit channel','data',...
    'interpreter','latex','location','northwest');
xlim([86 96]);
ylim([15,19.5]);
set(gca,'FontSize',12);

ah2 = axes('Parent',fig,'Units','normalized','Position',[0.41 0.5838 0.2134 0.3557]);
plot(year_model, baseline.agg_farmer(index_model).*100, '-b' , 'LineWidth', 2 );
hold on
plot(year_data1, farmer(index_data1).*100, '--k' , 'LineWidth', 2 );
hold on
plot(year_model, credit.agg_farmer(index_model).*100, '-.r' , 'LineWidth', 2 );
hold on
plot(year_model, deposit.agg_farmer(index_model).*100, ':g' , 'LineWidth', 2 );
title( 'B. Fraction of farmers', 'FontSize',15,'Interpreter','Latex');
xlabel('year', 'FontSize',12,'Interpreter','Latex');
ylabel('frac. of farmers (\%)', 'FontSize',12,'Interpreter','Latex');
xlim([86 96]);
ylim([25,50]);
set(gca,'FontSize',12);

ah3 = axes('Parent',fig,'Units','normalized','Position',[0.69 0.5838 0.2134 0.3557]);
plot(year_model, baseline.agg_worker(index_model).*100, '-b' , 'LineWidth', 2 );
hold on
plot(year_data1, worker(index_data1).*100, '--k' , 'LineWidth', 2 );
hold on
plot(year_model, credit.agg_worker(index_model).*100, '-.r' , 'LineWidth', 2 );
hold on
plot(year_model, deposit.agg_worker(index_model).*100, ':g' , 'LineWidth', 2 );
title( 'C. Fraction of workers', 'FontSize',15,'Interpreter','Latex');
xlabel('year', 'FontSize',12,'Interpreter','Latex');
ylabel('frac. of workers (\%)', 'FontSize',12,'Interpreter','Latex');
xlim([86 96]);
ylim([35,55]);
set(gca,'FontSize',12);
